package com.zh.mybatis.domain.student.mapper;

import com.zh.mybatis.domain.student.entity.CourseEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author ZH
 * @date 10:35 2021/9/1
 */
//会动态代理一个mapper实现类
@Mapper
public interface CourseMapper {
    
    @Select("select c.*, sc.student_id, sc.score" +
            "    from course c" +
            "    inner join student_2_course sc" +
            "    on c.id = sc.course_id" +
            "    where sc.student_id = #{studentId}")
    List<CourseEntity> findByStudent(@Param("studentId") Long studentId);

    @Select("SELECT * FROM course")
    List<CourseEntity> findAll();

}
